import Emberbox from "@/utils/mapbox/engine";
import { baseurl } from "../config";
import buildingsManage from "./buildingsManage";
import mapBoundaryManage from "./mapBoundaryManage";
import freedomsManage from "./freedomsManage";
import polygonsManage from "./polygonsManage";

const useInitLayerData = (emberbox: Emberbox) => {
  //记录场景信息
  let buildings: any = null; //建筑物buildings
  // 去目标附近
  emberbox.reset({
    center: [117.16324112036693, 39.12504588225827],
    zoom: 16,
  });

  //   事件

  //   查看geojson分区
  emberbox.on("onGeoJsonMouseon", (e: any) => {
    // console.log("鼠标移动到", e);
  });

  //   控制建筑buildings显示

  // 获取建筑物

  // fetch(`${baseurl}/buildings`)
  //   .then((res) => res.json())
  //   .then((res: any) => {
  //     buildings = emberbox.geojsonManage?.addIndoorJson(res);
  //     console.log("buildings", buildings);
  //   });

  mapBoundaryManage(emberbox); //医院外墙

  freedomsManage(emberbox); //好像时楼梯
  polygonsManage(emberbox); //内部房间
  buildingsManage(emberbox); //主体建筑
};

export default useInitLayerData;
